import QtQuick 6.8
import QtQuick.Controls 6.8
import QtQuick.Layouts 6.8
import "./Qml/Component"
import "./Qml"
ApplicationWindow {
    id: window
    visible: true  
    width: 840  
    height: 500 
    title: "Custom Window"
    flags: Qt.FramelessWindowHint  |
            Qt.Window |
            Qt.WindowMinimizeButtonHint |
            Qt.WindowMaximizeButtonHint |
            Qt.WindowCloseButtonHint 
    color: "transparent" // 透明背景
    background: Rectangle{
        color: WQTheme.background
        width:window.width
        height:window.height
        radius: WQTheme.macOS ? 10 : 0
        clip: true
        WQSystemBar {
            id: systemBar
            width: window.width
            height: WQTheme.macOS ? 35 : 30
            color: WQTheme.titleBackground
            title: window.title
            active: window.active
            nonClientArea: Row {
                anchors.fill: parent
                spacing: 10
                leftPadding: 10
                rightPadding: 10
                Image {
                    x:10
                    source: "Assert/images/logo.png"
                    width: 16
                    height: 16
                    anchors.verticalCenter: parent.verticalCenter
                }
                WQButton{
                    anchors.verticalCenter: parent.verticalCenter
                    text:"主页"
                    onClicked: stackView.currentIndex = 0
                    highlighted: stackView.currentIndex == 0
                }
                WQButton{
                    anchors.verticalCenter: parent.verticalCenter
                    text:"内容"
                    onClicked: stackView.currentIndex =  1
                    highlighted: stackView.currentIndex == 1
                     
                }
                
                WQButton{
                    id:aboutButton
                    anchors.verticalCenter: parent.verticalCenter
                    text:"关于"
                    onClicked: stackView.currentIndex = 2
                    highlighted: stackView.currentIndex == 2
                }
                 
                Switch{
                    anchors{
                        verticalCenter: parent.verticalCenter
                    }
                    onClicked: WQTheme.theme = !WQTheme.theme
                    text:""
                }
                Label {
                    anchors.verticalCenter: parent.verticalCenter
                    text: WQTheme.theme?"亮色":"暗色"
                    color: WQTheme.foreground  // Set your desired text color here
                    verticalAlignment: Text.AlignVCenter
                    horizontalAlignment: Text.AlignHCenter
                }

                Switch{
                    anchors{
                        verticalCenter: parent.verticalCenter
                    }
                    onClicked: WQTheme.macOS = !WQTheme.macOS
                    text:""
                }
                Label {
                    anchors.verticalCenter: parent.verticalCenter
                    text: WQTheme.macOS?"macOS":"windows"
                    color: WQTheme.foreground  // Set your desired text color here
                    verticalAlignment: Text.AlignVCenter
                    horizontalAlignment: Text.AlignHCenter
                }
            }
        }
        
        
    }
    StackLayout {
            id: stackView
            currentIndex: 0  
            y: systemBar.height
            width: window.width
            height: window.height - systemBar.height
            Home{

            }
            Content{ 
            
            }
            
            Item {
                WQButton{
                    text:"WuQi techlogy"
                }
            }
    }
    Component.onCompleted: {
        console.log("ApplicationWindow Component.onCompleted")
        setAcceptHoverEvents(true)
    }
}